﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BookManage
{
    public partial class Admin23 : Form
    {
        string old_id;
        public Admin23()
        {
            InitializeComponent();
        }
        public Admin23(string id,string name ,string author,string press ,string number)
        {
            InitializeComponent();
            old_id = id;
            textBox1.Text = id;
            textBox2.Text = name;
            textBox3.Text = author;       
            textBox4.Text = press;
            textBox5.Text = number;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string id = (string)textBox1.Text;
            string name = (string)textBox2.Text;
            string author = (string)textBox3.Text;
            string press = (string)textBox4.Text;
            string number = (string)textBox5.Text;
            int num = 0;
            try
            {
                 num = int.Parse(number);
            }
            catch
            {
                MessageBox.Show("库存输入项错误");
                textBox5.Text = "";
                return;
            }
            string sql = $"update t_book set id='{id}' ,name='{name}' ,author = '{author}', press='{press}',number={num} where id = '{old_id}'; ";


            Dao dao = new Dao();
            if (dao.Execute(sql)>0)
            {
                MessageBox.Show("修改成功");
                
            }
            else
            {
                MessageBox.Show("修改失败");
            }


        }
    }
}
